<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Update</title>
<script type="text/javascript">
		$(function() {
			var win = parent.$("iframe[title='商品管理']").get(0).contentWindow;//返回iframe页面文档（window)
		
			var row = win.$('#dg').datagrid("getSelected");
			//alert(row.supId);
			$('#ff').form('load',{
				goodsId:row.goodsId,
				goodsName:row.goodsName,
				goodsUnit:row.goodsUnit,
				goodsType:row.goodsType,
				goodsLimit:row.goodsLimit,
				goodsStore:row.goodsStore,
				goodsColor:row.goodsColor,
				goodsCommission:row.goodsCommission,
				goodsProducer:row.goodsProducer,
				goodsSelPrice:row.goodsSelPrice,
				goodsBuyPrice:row.goodsBuyPrice,
				goodsRemark:row.goodsRemark
			});
			
			$("[name='goodsName']").validatebox({
				required : true,
				missingMessage : '请填写商品名称！'
			});
			$("[name='goodsType']").validatebox({
				required : true,
				missingMessage : '请填写出商品种类！'
			});
			
			//禁用验证
			$("#ff").form("disableValidation");

			$("#btn").click(function() {
				$("#ff").form("enableValidation");
				if ($("#ff").form("validate")) {
					$('#ff').form('submit', {
						url : '${proPath}/goods/update.action',
						onSubmit : function() {
							return true;
						},
						success : function(count) {							
								//可以定义为对应消息框
								if(count > 0) {
                        	  	  	alert("修改成功!");
								} else {
									alert("操作失败!");
								}
								parent.$("#win").window("close");
								win.$("#dg").datagrid("reload");							
						}
					});

				}

			});

		});
</script>
</head>

<body>
	<form id="ff" method="post">
	    <div>
			<label for="goodsId">商品编号:</label> <input type="text" name="goodsId" readonly="readonly"/>
		</div>
		<div>
			<label for="goodsName">商品名称:</label> <input type="text" name="goodsName" />
		</div>
		<div>
			<label for="goodsType">商品种类:</label> <input type="text"
				name="goodsType" />
		</div>
		<div>
			<label for="goodsUnit">商品单位:</label> <input type="text"
				name="goodsUnit" />
		</div>
		<div>
			<label for="goodsLimit">库存下限:</label> <input type="text"
				name="goodsLimit" />
		</div>
		<div>
			<label for="goodsStore">库存:</label> <input type="text"
				name="goodsStore" />
		</div>
		<div>
			<label for="goodsCommission">商品佣金(%):</label> <input type="text"
				name="goodsCommission" />
		</div>
		<div>
			<label for="goodsColor">商品颜色:</label> 									
				<select id="cc" class="easyui-combobox" name="goodsColor" style="width:200px;">   
					<c:forEach items="${applicationScope.sysParam.goodsColor}" var="goodsColor">
					    <option value="${goodsColor.key}">${goodsColor.value}</option>   
					</c:forEach>   
				</select>  
		</div>
		<div>
			<label for="goodsProducer">生产商:</label> <input type="text"
				name="goodsProducer" />
		</div>
		<div>
			<label for="goodsSelPrice">售价:</label> <input type="text"
				name="goodsSelPrice" />
		</div>
		<div>
			<label for="goodsBuyPrice">成交价:</label> <input type="text"
				name="goodsBuyPrice" />
		</div>
		<div>
			<label for="goodsRemark">备注:</label>
			<textarea name="goodsRemark"></textarea>
		</div>
		<div>
			<input id="btn" type="button" value="提交" />
		</div>
	</form>
</body>
</html>